#include <iostream>
#include "Vec2D.h"
#include "MyClass.h"
#include "A.h"
#include "CPU.h"
#include "Array.h"
#include "B.h"
#include "Clock.h"
#include "Warrior.h"
#include "Queue.h"
#include "Complex.h"
using namespace std;

void test1();
void test2();
void test3();
void test4();
void test5();
void test6();
void test7();
void test8();
void test9();

int main() {
//    test1();
//    test2();
//    test3();
//    test4();
//    test5();
//    test6();
//    test7();
//    test8();
//    int a = 1, b = 2, c = 3;
//    a += b + c;
//    cout << a << b << c;

    const char* str[5] = {"1", "2", "3", "4", "5"};

    try {
        for(int i = 0; str[i]; i++){
            cout << str[i] << endl;
        }
    } catch (exception & e) {
        cout << "Pending" << endl;
    }


    cout << ">>" << endl;

    return 0;
}


void test1(){
    Vec2D v1(1, 3);
    Vec2D v2 = v1;
    Vec2D v3(v1);
    //v1.haha = 3;
    cout << "v1.x: " << &(v1.x) << endl;
    cout << "v1.y: " << &(v1.y) << endl;
    cout << "v2.x: " << &(v2.x) << endl;
    cout << "v2.y: " << &(v2.y) << endl;
    //cout << "v3.haha: " << v1.haha << endl;

    const MyClass obj1(10);
    MyClass obj2(20);
    obj1.Print();
    obj2.Print();

    A a;
    a.func(5);

    A *p = new A;
    p->func(5);

    A &r = a;
    r.func(5);

//    A b;
//    if(a != b){
//
//    }
}

void test2(){
    CPU a(P6, 3, 300);
    cout << "cpu a's parameter: " << endl;
    a.showinfo();
    CPU b;
    cout << "cpu b's parameter: " << endl;
    b.showinfo();
    CPU c(a);
    cout << "cpu c's parameter: " << endl;
    c.showinfo();
}

void test3(){
    ARRAY<int> a(50);
    int i;
    cin >> i;
    try {
        for(int j = 0; j < i; j++) a.at(i) = j;
    } catch (IndexError e) {
        cerr << "error!" << endl;
        return;
    }
}

void test4(){
    B b;
}

void test5(){
    int h, m, s;
    Clock  testClock;
    testClock.get(h, m, &s);
    cout << "OUT-1: " << h <<":" << m << ":" << s << endl; // OUT-1: 0:0:0
    testClock.adjust(13,5, 59);
    testClock.update();
    cout << "OUT-2: " << testClock << endl; // OUT-2: 13:6:0
    testClock.adjust(23,59, 58);
    testClock.update();
    cout << "OUT-3: " << testClock << endl; // OUT-3: 23:59:59
    testClock.update();
    cout << "OUT-4: " << testClock << endl; // OUT-4: 0:0:0
}

void test6(){
    A * p = new B;
    delete p;
}


void test7(){
    Fighter * objs[2];
    objs[0] = new Fighter("Harry");
    Warrior Stallone("Stallone", objs[0]);
    objs[1] = &Stallone;
    cout << "== Test the class famliy ==" << endl;
    for(int i=0; i<2; i++) {
        objs[i] -> outTitle();
        cout << "----  " << i+1 << "  ----" << endl;
        objs[i] -> hello();
    }
    cout << "==This is the end." << endl;
    delete objs[0];
}

void test8(){
    Queue q;
    --q;                                  // Display：The queue is empty!
    q = q + 5 + 6 + 3;
    cout << q;                      // Display：5   6   3
    cout << --q << endl;      // Display：5
    cout << q;                      // Display：6   3
    q = 9 + q;
    cout << q;                      // Display：6   3   9
    q = 2 + q;                      // Display：The queue is full!
    cout << q;                     // Display：6   3   9
}

void test9(){
    int i = 5;
    double d = 0;
    Complex cxa(1.3, -2), cxb = 2.5, cxc={1, -1};

//    10 + i;
//    d + i;
//    d + cxa;
//    cxc + 10;
//    i + d + cxb;
//    cxb = cxa + i;
//    cxa += cxb + cxc;
//    Complex cxd = cxb;
}








